If user directly close their browser without clicking logout then next time they open browser its session will be maintained as it is till they logout explicitly by clicking Logout button
I want to do it in vb.net !
Home / DeveloperSection / Forums / How to create remember me checkbox to remember session until user Logout explicitly
If user directly close their browser without clicking logout then next time they open browser its session will be maintained as it is till they logout explicitly by clicking Logout button
I want to do it in vb.net !
Aryan Kumar
06-Jul-2023Sure, I can help you with that. Here are the steps on how to create a remember me check box to remember session until user logout explicitly:
VB.Net
Here is an explanation of the code:
CheckedChanged
event is raised when the Checked property of the CheckBox control changes.HttpCookie
class represents a cookie.Value
property of theHttpCookie
class sets the value of the cookie.Expires
property of theHttpCookie
class sets the expiration date of the cookie.Cookies
property of theResponse
object gets the collection of cookies for the current request.Add
method of theCookies
property adds a cookie to the collection.Remove
method of theCookies
property removes a cookie from the collection.Sumit Kesarwani
26-Aug-2014Simply pass true as second parameter when emitting the authentication cookie:
FormsAuthentication.RedirectFromLoginPage(Username, true)
This will create a persistent authentication cookie on the client whose expiration is handled by the timeout property in your web.config: